<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\Http\Controllers\RecordController;
use App\Http\Controllers\GameController;
use App\Http\Controllers\PermissionsController;
use App\Http\Controllers\RolesController;
use App\Http\Controllers\TeamsController;
use App\Http\Middleware\CheckAES;

use App\Http\Middleware\RecordGet;
use App\Http\Middleware\RecordResponse;

use App\Http\Controllers\Record\FlyController;
use App\Http\Controllers\Record\KillController;
use App\Http\Controllers\Record\TeamController;
use App\Http\Controllers\Record\BunkoController;
use App\Http\Controllers\Record\TalkController;
use App\Http\Controllers\Record\FriendkillController;
use App\Http\Controllers\Record\PlayerController;
use App\Http\Controllers\ApiLogController;
use App\Http\Controllers\SubPermissionsController;
use App\Http\Controllers\Sub\SubRolesController;
use App\Http\Controllers\Sub\SubUserController;
use App\Http\Controllers\Sub\SubCodeController;
use App\Http\Controllers\Sub\MapController;
use App\Http\Controllers\Sub\SubTeamsController;
use App\Http\Controllers\Sub\SubMapController;
use App\Http\Controllers\CfgController;
use App\Http\Controllers\Sub\SubCfgController;
use App\Http\Controllers\Sub\SubSecretController;
use App\Http\Controllers\Sub\SubForbiddenController;
use App\Http\Controllers\Sub\SubGamerController;
use App\Http\Controllers\Sub\SubAuthorityController;
use App\Http\Controllers\Sub\SubApiLogController;
use App\Http\Controllers\Sub\SubCmdController;
use App\Http\Controllers\Sub\SubPlayerSecretController;
use App\Http\Controllers\NoticeController;
use App\Http\Controllers\MarkController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});


Route::get('/ping', function (Request $request) {
    return "pong";
});

Route::get('/ping/db', [UserController::class, 'ping']);


Route::post('/user/login', [UserController::class, 'login']);
Route::post('/user/register', [UserController::class, 'register']);
Route::post('/user/sendCode', [UserController::class, 'sendCode']);
Route::post('/user/forget',[UserController::class, 'forget']);
Route::post('/user/reset',[UserController::class, 'reset']);

Route::post('/user/init', [UserController::class, 'init']);
Route::post('/user/list', [UserController::class, 'list']);

Route::post('/user/add', [UserController::class, 'add']);
Route::post('/user/del', [UserController::class, 'del']);
Route::post('/user/edit', [UserController::class, 'edit']);
Route::post('/user/check', [UserController::class, 'check']);

Route::post('/forbidden/query', [SubForbiddenController::class, 'query']);
Route::post('/secret/query', [SubSecretController::class, 'query']);
Route::post('/secret/active', [SubSecretController::class, 'active']);
Route::post('/secret/carousel',[SubSecretController::class, 'carousel']);
Route::post('/forbidden/query',[SubForbiddenController::class, 'query']);


Route::middleware([CheckAES::class])->group(function(){
    // 飞天记录添加
    Route::post('/fly/add',[RecordController::class, 'fly_add'] );
    // 击杀记录添加
    Route::post('/killrecord/add',[RecordController::class, 'killrecord_add'] );
    // 建队记录添加
    Route::post('/teamrecord/add',[RecordController::class, 'teamrecord_add'] );
    // 输赢记录添加
    Route::post('/bunkorecord/add',[RecordController::class, 'bunkorecord_add'] );
    // 聊天记录添加
    Route::post('/talkrecord/add',[RecordController::class, 'talkrecord_add'] );
    // 玩家记录添加
    Route::post('/playrecord/add',[RecordController::class, 'playrecord_add'] );
    // 友伤记录添加
    Route::post('/friendkillrecord/add',[RecordController::class, 'friendkillrecord_add'] );
    // 玩家管理（添加）
    Route::post('/manageplayer/add',[GameController::class, 'manageplayer_add'] );
    // 密钥管理
    Route::post('/managesecret/add',[GameController::class, 'managesecret_add'] );
    // 封禁管理 (添加)
    Route::post('/manageforbidden/add',[GameController::class, 'manageforbidden_add'] );
    // 指令管理（数据回写表）
    Route::post('/managecmd/add',[GameController::class, 'managecmd_add'] );
    // 发送指令（测试）
    // Route::get('/managecmd/send',[GameController::class, 'managecmd_send'] );
    //获取服务器信息
    Route::post('/system/get',[GameController::class, 'system_get'] );
    //提交服务器信息
    Route::post('/system/add',[GameController::class, 'system_add'] );
    // 工会信息
    Route::post('/team/server/add',[GameController::class, 'team_add'] );
});
Route::middleware([RecordGet::class, RecordResponse::class])->group(function(){
    // 封禁管理 (获取)
    Route::post('/manageforbidden/get',[GameController::class, 'manageforbidden_get'] )->withoutMiddleware([RecordResponse::class]);
    // 飞天、击杀、建队、输赢、聊天、玩家、友伤记录获取
    Route::post('/record/get',[RecordController::class, 'record_get'] );
    // 样例文件获取
    Route::post('/example/get',[GameController::class, 'example_cfg'] )->withoutMiddleware([RecordResponse::class]);
    // 获取封禁管理cfg文件
    Route::post('/manageforbidden/cfg',[GameController::class, 'manageforbidden_cfg'] )->withoutMiddleware([RecordResponse::class]);
    //密钥管理
    Route::post('/managesecret/cfg',[GameController::class, 'managesecret_cfg'] )->withoutMiddleware([RecordResponse::class]);
    //权限管理
    Route::post('/managePermission/cfg',[GameController::class, 'managePermission_cfg'] )->withoutMiddleware([RecordResponse::class]);
    // 玩家管理（获取）
    Route::post('/manageplayer/get',[GameController::class, 'manageplayer_get'] );
});








//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});

Route::middleware('auth:sanctum')->group(function () {

    //主系统
    //用户管理
    Route::post('/user/init', [UserController::class, 'init']);
    Route::post('/user/del', [UserController::class, 'del']);
    Route::post('/user/edit', [UserController::class, 'edit']);
    Route::post('/user/list', [UserController::class, 'list']);
    Route::get('/user/loginOut', [UserController::class, 'loginOut']);

    //角色管理
    Route::post('/role/init', [RolesController::class, 'init']);
    Route::post('/role/add', [RolesController::class, 'add']);
    Route::post('/role/del', [RolesController::class, 'del']);
    Route::post('/role/edit', [RolesController::class, 'edit']);
    Route::post('/role/list', [RolesController::class, 'list']);

    //工会管理
    Route::post('/team/init', [TeamsController::class, 'init']);
    Route::post('/team/del', [TeamsController::class, 'del']);
    Route::post('/team/edit', [TeamsController::class, 'edit']);
    Route::post('/team/list', [TeamsController::class, 'list']);
    Route::post('/team/add', [TeamsController::class, 'add']);

    //地图管理
    Route::post('/map/init', [MapController::class, 'init']);
    Route::post('/map/del', [MapController::class, 'del']);
    Route::post('/map/edit', [MapController::class, 'edit']);
    Route::post('/map/list', [MapController::class, 'list']);
    Route::post('/map/add', [MapController::class, 'add']);
    Route::post('/map/json', [MapController::class, 'json']);

    //cfg管理
    Route::post('/cfg/init', [CfgController::class, 'init']);
    Route::post('/cfg/del', [CfgController::class, 'del']);
    Route::post('/cfg/edit', [CfgController::class, 'edit']);
    Route::post('/cfg/list', [CfgController::class, 'list']);
    Route::post('/cfg/add', [CfgController::class, 'add']);
    Route::post('/cfg/detail', [CfgController::class, 'detail']);


    Route::post('/user/changeProfile', [UserController::class, 'changeProfile']);
    Route::post('/user/detail', [UserController::class, 'detail']);
    Route::post('/user/permissions', [UserController::class, 'permissions']);
    Route::post('/user/trade', [UserController::class, 'trade']);

    //权限管理
    Route::post('/permission/init', [PermissionsController::class, 'init']);
    Route::post('/permission/add', [PermissionsController::class, 'add']);
    Route::post('/permission/del', [PermissionsController::class, 'del']);
    Route::post('/permission/edit', [PermissionsController::class, 'edit']);
    Route::post('/permission/list', [PermissionsController::class, 'list']);



    //操作日志
    Route::post('/log/selfList', [ApiLogController::class, 'selfList']);
    Route::post('/log/list', [ApiLogController::class, 'list']);
    Route::post('/log/del', [ApiLogController::class, 'del']);


    /*------------------------------- 子系统---------------------------------*/
    //获取权限菜单
    Route::post('/sub/user/permissions', [SubUserController::class, 'permissions']);
    Route::post('/sub/user/teamList', [SubUserController::class, 'teamList']);

    Route::post('/sub/user/init', [SubUserController::class, 'init']);
    Route::post('/sub/user/del', [SubUserController::class, 'del']);
    Route::post('/sub/user/edit', [SubUserController::class, 'edit']);
    Route::post('/sub/user/list', [SubUserController::class, 'list']);

    //玩家管理
    Route::post('/sub/gamer/init', [SubGamerController::class, 'init']);
    Route::post('/sub/gamer/del', [SubGamerController::class, 'del']);
    Route::post('/sub/gamer/edit', [SubGamerController::class, 'edit']);
    Route::post('/sub/gamer/list', [SubGamerController::class, 'list']);
    Route::post('/sub/gamer/detail', [SubGamerController::class, 'detail']);
    Route::post('/sub/gamer/option', [SubGamerController::class, 'option']);
    Route::post('/sub/gamer/teamOption', [SubGamerController::class, 'teamOption']);
    Route::post('/sub/gamer/globalOption', [SubGamerController::class, 'globalOption']);
    Route::post('/sub/gamer/black', [SubGamerController::class, 'black']);

    //操作日志
    Route::post('/sub/log/list', [SubApiLogController::class, 'list']);
    Route::post('/sub/log/del', [SubApiLogController::class, 'del']);


    //基于steamid进行标记
    Route::post('/sub/steam/detail', [SubGamerController::class, 'list']);

    //预设地图
    Route::post('/sub/map/init', [SubMapController::class, 'init']);
    Route::post('/sub/map/edit', [SubMapController::class, 'edit']);
    Route::post('/sub/map/list', [SubMapController::class, 'list']);

    //在线指令
    Route::post('/sub/cmd/list', [SubCmdController::class, 'list']);
    Route::post('/sub/cmd/push', [SubCmdController::class, 'push']);

    //权限管理
    Route::post('/sub/authority/init', [SubAuthorityController::class, 'init']);
    Route::post('/sub/authority/add', [SubAuthorityController::class, 'add']);
    Route::post('/sub/authority/edit', [SubAuthorityController::class, 'edit']);
    Route::post('/sub/authority/list', [SubAuthorityController::class, 'list']);
    Route::post('/sub/authority/del', [SubAuthorityController::class, 'del']);

    //密钥管理
    Route::post('/sub/secret/init', [SubSecretController::class, 'init']);
    Route::post('/sub/secret/del', [SubSecretController::class, 'del']);
    Route::post('/sub/secret/edit', [SubSecretController::class, 'edit']);
    Route::post('/sub/secret/list', [SubSecretController::class, 'list']);
    Route::post('/sub/secret/add', [SubSecretController::class, 'add']);
    Route::post('/sub/secret/active', [SubSecretController::class, 'active']);

    //激活列表
    Route::post('/sub/active/init', [SubPlayerSecretController::class, 'init']);
    Route::post('/sub/active/del', [SubPlayerSecretController::class, 'del']);
    Route::post('/sub/active/list', [SubPlayerSecretController::class, 'list']);

    //封禁管理
    Route::post('/sub/forbidden/init', [SubForbiddenController::class, 'init']);
    Route::post('/sub/forbidden/del', [SubForbiddenController::class, 'del']);
    Route::post('/sub/forbidden/edit', [SubForbiddenController::class, 'edit']);
    Route::post('/sub/forbidden/list', [SubForbiddenController::class, 'list']);
    Route::post('/sub/forbidden/add', [SubForbiddenController::class, 'add']);
    Route::post('/sub/forbidden/approve', [SubForbiddenController::class, 'approve']);
    Route::post('/sub/forbidden/refuse', [SubForbiddenController::class, 'refuse']);
    Route::post('/sub/forbidden/cancel', [SubForbiddenController::class, 'cancel']);

    //系统配置
    Route::post('/sub/team/detail/init', [SubTeamsController::class, 'detailInit']);
    Route::post('/sub/team/detail', [SubTeamsController::class, 'detail']);
    Route::post('/sub/team/edit/server', [SubTeamsController::class, 'editServer']);
    Route::post('/sub/team/edit/dict', [SubTeamsController::class, 'editDict']);
    Route::post('/sub/team/update', [SubTeamsController::class, 'updateServer']);
    Route::post('/sub/team/open', [SubTeamsController::class, 'open']);


    //文件管理
    Route::post('/sub/cfg/init', [SubCfgController::class, 'init']);
    Route::post('/sub/cfg/del', [SubCfgController::class, 'del']);
    Route::post('/sub/cfg/edit', [SubCfgController::class, 'edit']);
    Route::post('/sub/cfg/list', [SubCfgController::class, 'list']);
    Route::post('/sub/cfg/add', [SubCfgController::class, 'add']);
    Route::post('/sub/cfg/copy', [SubCfgController::class, 'copy']);
    Route::post('/sub/cfg/detail', [SubCfgController::class, 'detail']);


    //权限管理
    Route::post('/permission/sub/init', [SubPermissionsController::class, 'init']);
    Route::post('/permission/sub/add', [SubPermissionsController::class, 'add']);
    Route::post('/permission/sub/del', [SubPermissionsController::class, 'del']);
    Route::post('/permission/sub/edit', [SubPermissionsController::class, 'edit']);
    Route::post('/permission/sub/list', [SubPermissionsController::class, 'list']);


    // 邀请码管理
    Route::post('/sub/code/init', [SubCodeController::class, 'init']);
    Route::post('/sub/code/add', [SubCodeController::class, 'add']);
    Route::post('/sub/code/del', [SubCodeController::class, 'del']);
    Route::post('/sub/code/edit', [SubCodeController::class, 'edit']);
    Route::post('/sub/code/list', [SubCodeController::class, 'list']);
    Route::post('/sub/code/join', [SubCodeController::class, 'join']);


    //角色管理
    Route::post('/sub/role/init', [SubRolesController::class, 'init']);
    Route::post('/sub/role/add', [SubRolesController::class, 'add']);
    Route::post('/sub/role/del', [SubRolesController::class, 'del']);
    Route::post('/sub/role/edit', [SubRolesController::class, 'edit']);
    Route::post('/sub/role/list', [SubRolesController::class, 'list']);


    //信息展示-飞天记录
    Route::post('/record/fly/init', [FlyController::class, 'init']);
    Route::post('/record/fly/del', [FlyController::class, 'del']);
    Route::post('/record/fly/edit', [FlyController::class, 'edit']);
    Route::post('/record/fly/list', [FlyController::class, 'list']);
    Route::post('/record/fly/add', [FlyController::class, 'add']);

    //信息展示-击杀记录
    Route::post('/record/kill/init', [KillController::class, 'init']);
    Route::post('/record/kill/del', [KillController::class, 'del']);
    Route::post('/record/kill/edit', [KillController::class, 'edit']);
    Route::post('/record/kill/list', [KillController::class, 'list']);
    Route::post('/record/kill/add', [KillController::class, 'add']);

    //信息展示-建队记录
    Route::post('/record/team/init', [TeamController::class, 'init']);
    Route::post('/record/team/del', [TeamController::class, 'del']);
    Route::post('/record/team/edit', [TeamController::class, 'edit']);
    Route::post('/record/team/list', [TeamController::class, 'list']);
    Route::post('/record/team/add', [TeamController::class, 'add']);

    //信息展示-输赢记录
    Route::post('/record/bunko/init', [BunkoController::class, 'init']);
    Route::post('/record/bunko/del', [BunkoController::class, 'del']);
    Route::post('/record/bunko/edit', [BunkoController::class, 'edit']);
    Route::post('/record/bunko/list', [BunkoController::class, 'list']);
    Route::post('/record/bunko/add', [BunkoController::class, 'add']);

    //信息展示-聊天记录
    Route::post('/record/talk/init', [TalkController::class, 'init']);
    Route::post('/record/talk/del', [TalkController::class, 'del']);
    Route::post('/record/talk/edit', [TalkController::class, 'edit']);
    Route::post('/record/talk/list', [TalkController::class, 'list']);
    Route::post('/record/talk/add', [TalkController::class, 'add']);

    //信息展示-友伤记录
    Route::post('/record/friendkill/init', [FriendkillController::class, 'init']);
    Route::post('/record/friendkill/del', [FriendkillController::class, 'del']);
    Route::post('/record/friendkill/edit', [FriendkillController::class, 'edit']);
    Route::post('/record/friendkill/list', [FriendkillController::class, 'list']);
    Route::post('/record/friendkill/add', [FriendkillController::class, 'add']);

    //信息展示-玩家记录
    Route::post('/record/player/init', [PlayerController::class, 'init']);
    Route::post('/record/player/del', [PlayerController::class, 'del']);
    Route::post('/record/player/edit', [PlayerController::class, 'edit']);
    Route::post('/record/player/list', [PlayerController::class, 'list']);
    Route::post('/record/player/add', [PlayerController::class, 'add']);

    //公告
    Route::post('/notice/info', [NoticeController::class, 'info']);

    // 标记
    Route::post('/mark/add', [MarkController::class, 'add']);
    Route::post('/mark/list', [MarkController::class, 'list']);
    Route::post('/mark/del', [MarkController::class, 'del']);
    Route::post('/mark/listmain', [MarkController::class, 'listmain']);
    Route::post('/mark/init', [MarkController::class, 'init']);
    Route::post('/mark/adminDel', [MarkController::class, 'adminDel']);
});




